//
//  DYEmployeeManagementVC.m
//  kafuMerchant
//
//  Created by 帝云科技 on 2018/9/18.
//  Copyright © 2018年 帝云科技. All rights reserved.
//

#import "DYEmployeeManagementVC.h"
#import "DYEmployeeView.h"
#import "DYEmployeeCell.h"
#import "DYAddEmployeeVC.h"

@interface DYEmployeeManagementVC ()

@property (nonatomic,strong)DYEmployeeView *headerView;

@end

@implementation DYEmployeeManagementVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title=@"员工管理";
    self.navigationItem.rightBarButtonItems=@[[[UIBarButtonItem alloc]initWithImage:IMG(@"icon_nav_plus") style:UIBarButtonItemStylePlain target:self action:@selector(rightItemClick:)],[[UIBarButtonItem alloc]initWithImage:IMG(@"icon_nav_search") style:UIBarButtonItemStylePlain target:self action:@selector(rightItemClick:)]];
}
-(void)rightItemClick:(UIBarButtonItem *)item
{
    if (item==self.navigationItem.rightBarButtonItems[0]) {
        DYAddEmployeeVC *vc=[[DYAddEmployeeVC alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }else{
     
    }
}
-(void)dy_initUI
{
    [super dy_initUI];
    
    [self.view addSubview:self.headerView];
    
    self.tableView.frame=CGRectMake(0, self.headerView.xhq_bottom, kScreenWidth, kScreenHeight-kNavigationStatusHeight-self.headerView.xhq_height);
    
    self.tableView.backgroundColor=WhiteColor;
    
    [self.tableView registerClass:[DYEmployeeCell class] forCellReuseIdentifier:@"DYEmployeeCell"];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 3;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return BILIHEIGHT(40);
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    DYEmployeeCell *cell=[tableView dequeueReusableCellWithIdentifier:@"DYEmployeeCell" forIndexPath:indexPath];
    return cell;
}
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    editingStyle=UITableViewCellEditingStyleDelete;
}
-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
    return YES;
}
-(NSArray <UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewRowAction *deleteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"删除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
        NSLog(@"点击了删除");
        
    }];
    deleteAction.backgroundColor=[UIColor xhq_red];
    UITableViewRowAction *editAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"编辑" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
        NSLog(@"点击了编辑");
    }];
    editAction.backgroundColor = [UIColor xhq_base];
    return @[deleteAction, editAction];
}
-(DYEmployeeView *)headerView
{
    if (!_headerView) {
        _headerView=[[DYEmployeeView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, BILIHEIGHT(40))];
        _headerView.backgroundColor=WhiteColor;
    }
    return _headerView;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
